{% load i18n %}
{% load eventurl %}
{% for subev in subevent_list %}
    <a href="{% if request.GET.voucher %}{% eventurl event "presale:event.redeem" cart_namespace=cart_namespace %}?voucher={{ request.GET.voucher|urlencode }}&subevent={{ subev.pk }}{% else %}{% eventurl event "presale:event.index" subevent=subev.id cart_namespace=cart_namespace %}{% endif %}"
            class="subevent-row">
        <div class="row">
            <div class="col-md-6">
                <strong>{{ subev.name }}</strong>
            </div>
            <div class="col-md-4">
                <span class="fa fa-calendar" aria-hidden="true"></span>
                {{ subev.get_date_range_display }}
                {% if event.settings.show_times %}
                    <span data-time="{{ subev.date_from.isoformat }}" data-timezone="{{ event.timezone }}" data-time-short>
                        <span class="fa fa-clock-o" aria-hidden="true"></span>
                        {{ subev.date_from|date:"TIME_FORMAT" }}
                    </span>
                {% endif %}
            </div>
            <div class="col-md-2 text-right flip">
                {% if subev.presale_is_running and event.settings.event_list_availability %}
                    {% if subev.best_availability_state == 100 %}
                        <span class="label label-success">{% trans "Book now" %}</span>
                    {% elif event.settings.waiting_list_enabled and subev.best_availability_state >= 0 %}
                        <span class="label label-warning">{% trans "Waiting list" %}</span>
                    {% elif subev.best_availability_state == 20 %}
                        <span class="label label-warning">{% trans "Reserved" %}</span>
                    {% elif subev.best_availability_state < 20 %}
                        {% if subev.has_paid_item %}
                            <span class="label label-danger">{% trans "Sold out" %}</span>
                        {% else %}
                            <span class="label label-danger">{% trans "Fully booked" %}</span>
                        {% endif %}
                    {% endif %}
                {% elif subev.presale_is_running %}
                    <span class="label label-success">{% trans "Book now" %}</span>
                {% elif subev.presale_has_ended %}
                    <span class="label label-danger">{% trans "Sale over" %}</span>
                {% elif event.settings.presale_start_show_date %}
                    <span class="label label-warning">
                                    {% blocktrans trimmed with date=subev.effective_presale_start|date:"SHORT_DATE_FORMAT" %}
                                        Sale starts {{ date }}
                                    {% endblocktrans %}
                                </span>
                {% else %}
                    <span class="label label-warning">{% trans "Not yet on sale" %}</span>
                {% endif %}
            </div>
        </div>
    </a>
{% endfor %}
